package com.glory.brepda.adapter;

import android.view.View;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.brepda.R;
import com.glory.brepda.entity.LotInfoEntity;

import java.util.List;

public class LotBatchListAdapter extends BaseQuickAdapter<LotInfoEntity.LotBean, BaseViewHolder> {

    private boolean showEqp = false;
    private onDeleteListener deleteListener;

    public LotBatchListAdapter(@Nullable List<LotInfoEntity.LotBean> data,boolean showEqp,onDeleteListener listener) {
        super(R.layout.adapter_lot_batch,data);
        this.showEqp = showEqp;
        this.deleteListener = listener;
    }

    @Override
    protected void convert(BaseViewHolder helper, LotInfoEntity.LotBean item) {
        helper.setText(R.id.tvLotID,String.valueOf(item.getLOTID()))
                .setText(R.id.tvStep,item.getSTEPDESC())
                .setText(R.id.tvLotQTY,item.getMAINQTY())
                .setText(R.id.tvStates,item.getSTATE())
                .setText(R.id.tvEqpID,item.getEQUIPMENTID())
                .setGone(R.id.tvEqpID,showEqp);

        helper.getView(R.id.ivDelete).setOnClickListener(view -> {
            remove(helper.getAdapterPosition());
            if (deleteListener != null){
                deleteListener.setOnDeleteListener();
            }
        });

    }

    public interface onDeleteListener{
        void setOnDeleteListener();
    }
}
